home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 051-075 / disk_056 / mcad / mp / source / mp.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  19KB  |  548 lines

  1. /***************************************************************************
  2. *                    Copyright (c) 1986, Tim Mooney                        *
  3. *                                                                          *
  4. *      This software is released into the public domain.  You may use,     *
  5. *   copy, modify, and redistribute it if this notice is retained.  You     *
  6. *   may not sell it, but you may charge a nominal copying/hassle fee for   *
  7. *   making it available.                                                   *
  8. *                                                                          *
  9. *      MP is not finished.  Send comments, suggestions, etc. to            *
  10. *                                                                          *
  11. *                                            Tim Mooney                    *
  12. *                                            120 Purefoy Rd.               *
  13. *                                            Chapel Hill NC  27514         *
  14. ***************************************************************************/
  15.  
  16. /***************************************************************************
  17. *   mp.c - PLOT DATA EMBEDDED IN TEXT FILE
  18. *
  19. *      Mp reads a text file and extracts data from it in a user-defined way.
  20. *   (See getdat.c for details.  Also, interactive help is available.)
  21. *   When the data are collected, mp opens a high-res screen, and plots some
  22. *   or all of the data -- again, in a user-defined way.  Some of the
  23. *   details of plotting specifications (keywords: "how_to string") are
  24. *   explained in the file sample.dat.  Interactive help is also available
  25. *   from the function GetHowTo().
  26. ****************************************************************************
  27. *   Capabilities, limitations, and implementation notes:
  28. *
  29. *      Mp can plot lines or points of varying sizes; with or without error
  30. *   bars; in 10 colors.  There is no internal limit on the number of data
  31. *   sets plotted simultaneously, or on the number of points in a single
  32. *   data set, or on the total size of all data sets.  Memory is allocated
  33. *   dynamically; when it's used up, mp will stop processing the data file
  34. *   and crash when it tries to open a new screen.
  35. *
  36. *      Points are actually drawn as squares, except for the smallest sizes.
  37. *   Mp doesn't plot any other kinds of marks.  Points may be any size; one
  38. *   may fill the screen, in fact.  All lines are solid, error bars are
  39. *   lines.
  40. *
  41. *      GetDat() can scale data on input, directed by information in the
  42. *   data file it's reading.  Although GetDat() can also extract a title and
  43. *   labels from the data file, mp makes no use of them at present.  
  44. *
  45. *      Once the data are plotted on the screen, the user can zoom in and
  46. *   out, disable axes and grid, etc.  Also, the current picture can be
  47. *   dumped to a file for plotting.  The only plotter language supported
  48. *   is HPGL (Hewlett-Packard) since it's the only one I know.
  49. *
  50. *      Fast Floating Point routines are used throughout.
  51. ***************************************************************************/
  52.  
  53. #include <stdio.h>
  54. #include <exec/types.h>
  55. #include <exec/memory.h>
  56. #include "struct.h"
  57. #include "plotlim.h"
  58.  
  59. extern int GetDat();
  60. extern void plot();
  61.  
  62. long GfxBase = 0;
  63. long IntuitionBase = 0;
  64. int debug = FALSE;
  65.  
  66. FFP xtic[MAXTICS],ytic[MAXTICS];
  67. short xticp[MAXTICS],yticp[MAXTICS];
  68. char filename[30];
  69.  
  70. main(argc,argv)
  71. char *argv[];
  72. int argc;
  73. {
  74.  
  75.    register short i, j;
  76.    int help=FALSE;
  77.    int xcol=1, ycol=2, ecol=0, terse=TRUE;
  78.    char c;
  79.    FILE *fp;
  80.    struct Pict *Pict;
  81.  
  82.    /*** PARSE ARGS ***/
  83.    filename[0] = 0;
  84.    for (i=1; i<argc; i++) {
  85.       if (argv[i][0] == '-') {
  86.          j=1;
  87.          while (c = argv[i][j++]) {
  88.             switch (c) {
  89.                case 'd':   debug = TRUE; break;
  90.                case 'h':   help = TRUE; break;
  91.                case 'v':   terse = FALSE; break;
  92.                case 'x':
  93.                   xcol = isdigit(argv[i][j]) ? atoi(&argv[i][j++]) : 0;
  94.                   ycol=xcol+1;
  95.                   break;
  96.                case 'y':
  97.                   ycol = isdigit(argv[i][j]) ? atoi(&argv[i][j++]) : xcol+1;
  98.                   break;
  99.                case 'e':
  100.                   ecol = isdigit(argv[i][j]) ? atoi(&argv[i][j++]) : ycol+1;
  101.                   break;
  102.             }
  103.          }
  104.       }
  105.       else if (argv[i][0] == '?')
  106.          help = TRUE;
  107.       else
  108.          strcpy(filename,argv[i]);
  109.    }
  110.  
  111.    if (help || !(*filename)) {
  112.       printf("usage: \x9b2mmp\x9bm [\x9b2m-x\x9bm[\x9b2m#\x9bm]\x9b2my\x9bm[\x9b2m#\x9bm]\x9b2me\x9bm[\x9b2m#\x9bm]\x9b2mvd\x9bm]\x9b2m filename\x9bm\n");
  113.       printf("   \x9b2m-x\x9bm[\x9b2m#\x9bm] x in col # (if 0, no x) default:1\n");
  114.       printf("   \x9b2m-y\x9bm[\x9b2m#\x9bm] y in col # (err if #=0) default:x_col+1\n");
  115.       printf("   \x9b2m-e\x9bm[\x9b2m#\x9bm] e in col # (if 0, no e) default:0 (no \x9b2me\x9bm); x_col+2 (\x9b2me\x9bm but no \x9b2m#\x9bm)\n");
  116.       printf("   \x9b2m-v\x9bm    verbose file inspection default:terse\n");
  117.       printf("   \x9b2m-d\x9bm    debug on                default:off\n");
  118.       printf("\nEXAMPLE: mp -x0y1e2 mydatafile.dat\n");
  119.       printf("   for a file containing y data in column 1, err_in_y data\n");
  120.       printf("   in column 2, and no x data. (relative line # used for x)\n");
  121.       exit(0);
  122.    }
  123.    
  124.  
  125.    /*** OPEN LIBRARIES ***/
  126.    FFPLARGE = 1.0e10; FFPSMALL = 1.0e-10;
  127.    
  128.    GfxBase = OpenLibrary("graphics.library",0);
  129.    if(GfxBase == NULL) {
  130.       printf("Can't open graphics library...\n");
  131.       exit(1);
  132.    }
  133.    IntuitionBase = OpenLibrary("intuition.library",0);
  134.    if(IntuitionBase == NULL) {
  135.       printf("Can't open intuition library...\n");
  136.       exit(1);
  137.    }
  138.  
  139.    /*** OPEN FILE ***/
  140.    fp = fopen(filename,"r");
  141.    if (!fp) {
  142.       printf("can't open %s\n",filename);
  143.       exit(1);
  144.    }
  145.  
  146.    /*** ALLOCATE/INITIALIZE MEMORY FOR struct Pict ***/
  147.    Pict = (struct Pict *)AllocMem(sizeof(struct Pict),MEMF_CLEAR);
  148.    Pict->ErrBar = (ecol != 0);
  149.    Pict->Tics = (struct Tics *)AllocMem(sizeof(struct Tics),MEMF_CLEAR);
  150.    Pict->Tics->x = xtic;Pict->Tics->y = ytic;
  151.    Pict->Tics->xp = xticp;Pict->Tics->yp = yticp;
  152.    Pict->XRegionLock = Pict->YRegionLock = FALSE;
  153.    Pict->Axes = TRUE;
  154.    Pict->CurrReg =
  155.       (struct PlotRegion *)AllocMem(sizeof(struct PlotRegion),MEMF_CLEAR);
  156.    Pict->NewReg =
  157.       (struct PlotRegion *)AllocMem(sizeof(struct PlotRegion),MEMF_CLEAR);
  158.    Pict->Title = NULL;
  159.    Pict->XLabel = NULL;
  160.    Pict->YLabel = NULL;
  161.    Pict->Plot = NULL;
  162.  
  163.    /*** GET DATA FROM FILE ***/
  164.    GetDat(fp, xcol, ycol, ecol, terse, Pict);
  165.    if (debug) printf("mp: closing data file\n");
  166.    (void) fclose(fp);
  167.  
  168.  
  169.    /*** PLOT DATA ***/
  170.    plot(Pict);
  171.  
  172.    /*** DEALLOCATE MEMORY ***/
  173.    FreeMem(Pict->NewReg,sizeof(struct PlotRegion));
  174.    FreeMem(Pict->CurrReg,sizeof(struct PlotRegion));
  175.    FreeMem(Pict->Tics,sizeof(struct Tics));
  176.    FreeMem(Pict,sizeof(struct Pict));
  177.    FreeStructPlot();
  178.    return(0);
  179. }
  180.  
  181. /************************************************/
  182. #define P_XREG 10000
  183. #define P_YREG 10000
  184. #define P_X_TIC_SIZE X_TIC_SIZE*(P_YREG/MAXVERT)
  185. #define P_Y_TIC_SIZE Y_TIC_SIZE*(P_XREG/MAXHORIZ)
  186. #define P_CH_WID 75
  187. #define P_CH_HEI 150
  188. #define P_LMARGIN P_CH_WID*8
  189. #define P_BMARGIN P_CH_HEI*2
  190. #define P_TMARGIN 0
  191. #define P_RMARGIN 0
  192.  
  193. static FFP XScale, YScale, XOffset, YOffset;
  194.  
  195. void fWrtFFP(fp, ffpval)
  196. FILE *fp;
  197. FFP ffpval;
  198. {
  199.    fprintf(fp, "%d", (int)ffpval);
  200. }
  201.  
  202.  
  203. void WrtAxes(fp, Tics, Grid)
  204. FILE *fp;
  205. struct Tics *Tics;
  206. short Grid;
  207. {
  208.    short n, tmpx, tmpy, i;
  209.    FFP *x, *y;
  210.    char tmpstr[20];
  211.       
  212.    /*** DRAW BORDER ***/
  213.    fprintf(fp,"SP1;PU%d %d;",P_LMARGIN,P_BMARGIN);
  214.    fprintf(fp,"PD%d %d %d %d %d %d %d %d;\n",P_XREG,P_BMARGIN,P_XREG,P_YREG,
  215.    P_LMARGIN,P_YREG,P_LMARGIN,P_BMARGIN);
  216.  
  217.    /*** DRAW TICS/GRID ***/
  218.    fprintf(fp,"SP2;");
  219.    x=Tics->x; y=Tics->y;
  220.    for (i=1; i < Tics->NX; i++) {
  221.       if (Grid) {
  222.          fprintf(fp,"PU"); fWrtFFP(fp,(XScale * (XOffset + x[i])));
  223.          fprintf(fp," %d;PD",P_BMARGIN);
  224.          fWrtFFP(fp,(XScale * (XOffset + x[i])));
  225.          fprintf(fp," %d;\n",P_YREG);
  226.       }
  227.       else {
  228.          fprintf(fp,"PU"); fWrtFFP(fp,(XScale * (XOffset + x[i])));
  229.          fprintf(fp," %d;PD",P_BMARGIN);
  230.          fWrtFFP(fp,(XScale * (XOffset + x[i])));
  231.          fprintf(fp," %d;",P_BMARGIN + P_X_TIC_SIZE);
  232.          fprintf(fp,"PU"); fWrtFFP(fp,(XScale * (XOffset + x[i])));
  233.          fprintf(fp," %d;PD",P_YREG);
  234.          fWrtFFP(fp,(XScale * (XOffset + x[i])));
  235.          fprintf(fp," %d;\n",P_YREG - P_X_TIC_SIZE);
  236.       }
  237.    }
  238.    for (i=1; i < Tics->NY; i++) {
  239.       if (Grid) {
  240.          fprintf(fp,"PU%d ",P_LMARGIN);
  241.          fWrtFFP(fp,(YScale * (YOffset + y[i])));
  242.          fprintf(fp,"PD%d ",P_XREG);
  243.          fWrtFFP(fp,(YScale * (YOffset + y[i])));
  244.          fprintf(fp,";\n");
  245.       }
  246.       else {
  247.          fprintf(fp,"PU%d ",P_LMARGIN);
  248.          fWrtFFP(fp,(YScale * (YOffset + y[i])));
  249.          fprintf(fp,";PD%d ", P_LMARGIN + P_Y_TIC_SIZE);
  250.          fWrtFFP(fp,(YScale * (YOffset + y[i])));
  251.          fprintf(fp,";");
  252.          fprintf(fp,"PU%d ",P_XREG);
  253.          fWrtFFP(fp,(YScale * (YOffset + y[i])));
  254.          fprintf(fp,";PD%d ", P_XREG - P_Y_TIC_SIZE);
  255.          fWrtFFP(fp,(YScale * (YOffset + y[i])));
  256.          fprintf(fp,";\n");
  257.       }
  258.    }
  259.  
  260.    /*** PRINT TIC VALUES ***/
  261.    fprintf(fp,"SP1;");
  262.    for (i=0; i < Tics->NX; i++) {
  263.       n = sprintf(tmpstr, "%-.4f", Tics->x[i]);
  264.       n = min(n, 7);
  265.       while (tmpstr[n-1] == '0') n--;
  266.       tmpstr[n]=0;
  267.       tmpx = (short)((XScale * (XOffset + Tics->x[i])));
  268.       tmpx -= (((n+1)/2)-.5) * P_CH_WID;
  269.       fprintf(fp, "PU%d 1;", tmpx);
  270.       fprintf(fp,"LB%s\003", tmpstr);
  271.    }
  272.    for (i=0; i < Tics->NY; i++) {
  273.       n = sprintf(tmpstr, "%-.4f", Tics->y[i]);
  274.       n = min(n, 7);
  275.       while (tmpstr[n-1] == '0') n--;
  276.       tmpstr[n]=0;
  277.       tmpy = (short)((YScale * (YOffset + Tics->y[i])));
  278.       tmpy -= .5 * P_CH_WID;
  279.       fprintf(fp, "PU1 %d;", tmpy);
  280.       fprintf(fp,"LB%s\003", tmpstr);
  281.    }
  282. }
  283.  
  284.  
  285. extern char *stpchr();
  286.  
  287. WrtPlt(Pict)
  288. struct Pict *Pict;
  289. {
  290.    FILE *fp;
  291.    short i;
  292.    struct Plot *Plot;
  293.    FFP *x, *y, *e;
  294.    short xptsiz, yptsiz;
  295.    char plotname[30], *chptr;
  296.    static char PlotNum = 0;
  297.  
  298.    strcpy(plotname,filename);
  299.    if (chptr = stpchr(plotname,'.')) {
  300.       chptr[1]='p'; chptr[2]='l'; chptr[3]='t';
  301.       chptr[4] = '0' + PlotNum; chptr[5]=0;
  302.    }
  303.    else {
  304.       i=strlen(plotname); plotname[i]='.';
  305.       plotname[i+1]='p'; plotname[i+2]='l'; plotname[i+3]='t';
  306.       plotname[i+4] = '0' + PlotNum; plotname[i+5]=0;
  307.    }
  308.    
  309.    if (!(fp = fopen(plotname,"w") ))
  310.       {printf("can't open %s\n",plotname); return(FALSE);}
  311.  
  312.    fprintf(fp,"IN;SC 0 %d 0 %d;\n", P_XREG+2, P_YREG+2);
  313.    fprintf(fp,"VS 20.0;\n");  /* VELOCITY cm/s */
  314.    fprintf(fp,"\033.N;19:\033.I81;;17:\n"); /* XON/XOFF */
  315.    XScale = (FFP)(P_XREG - P_LMARGIN - P_RMARGIN) /
  316.             (Pict->CurrReg->XMax - Pict->CurrReg->XMin);
  317.    YScale = (FFP)(P_YREG - P_BMARGIN - P_TMARGIN) /
  318.             (Pict->CurrReg->YMax - Pict->CurrReg->YMin);
  319.    XOffset = (FFP)(P_LMARGIN) / XScale - Pict->CurrReg->XMin;
  320.    YOffset = (FFP)(P_BMARGIN) / YScale - Pict->CurrReg->YMin;
  321.  
  322.    Plot = Pict->Plot;
  323.    while (Plot) {
  324.       if (Plot->Enabled) {
  325.          fprintf(fp,"PU;SP%d;\n", 1+Plot->Color-PLOTCOLORBASE);
  326.  
  327.          /* PLOT LINES */
  328.          if (Plot->PointSize <= 0) {
  329.             x=Plot->x; y=Plot->y;
  330.             fprintf(fp, "PU"); fWrtFFP(fp,(XScale * (XOffset + *x)));
  331.             fprintf(fp," ");
  332.             fWrtFFP(fp,(YScale * (YOffset + *y))); fprintf(fp,";");
  333.             x++; y++;
  334.             fprintf(fp, "PD");
  335.             for (i=1; i<Plot->NPts; i++, x++, y++) {
  336.                if (i>1) fprintf(fp, " ");
  337.                fWrtFFP(fp,(XScale * (XOffset + *x)));
  338.                fprintf(fp," ");
  339.                fWrtFFP(fp,(YScale * (YOffset + *y)));
  340.             }
  341.             fprintf(fp,";\n");
  342.          }
  343.  
  344.          /* PLOT POINTS */
  345.          if (Plot->PointSize != 0) {
  346. /*            xptsiz = abs(Plot->PointSize) * (P_XREG / (100 * 11));  */
  347. /*            yptsiz = abs(Plot->PointSize) * (P_YREG / (100 * 8.5)); */
  348.             xptsiz = abs(Plot->PointSize) * (P_XREG / 1100);
  349.             yptsiz = abs(Plot->PointSize) * (P_YREG / 850);
  350.             x=Plot->x; y=Plot->y;
  351.             for (i=0; i<Plot->NPts; i++, x++, y++) {
  352.                fprintf(fp,"PU");
  353.                fWrtFFP(fp,(XScale * (XOffset + *x)));
  354.                fprintf(fp," ");
  355.                fWrtFFP(fp,(YScale * (YOffset + *y)));
  356.                fprintf(fp,";");
  357.                fprintf(fp,"PR%d %d;", -xptsiz/2, -yptsiz/2);
  358.                fprintf(fp,"PD%d 0 0 %d %d 0 0 %d;PA;\n",
  359.                      xptsiz, yptsiz, -xptsiz, -yptsiz);
  360.             }
  361.          }
  362.  
  363.          /* PLOT ERROR BARS */
  364.          if (Pict->ShowErr) {
  365.             x=Plot->x; y=Plot->y; e=Plot->e;
  366.             for (i=0; i<Plot->NPts; i++, x++, y++, e++) {
  367.                fprintf(fp,"PU");
  368.                fWrtFFP(fp,(XScale * (XOffset + *x)));
  369.                fprintf(fp," ");
  370.                fWrtFFP(fp,(YScale * (YOffset + (*y - *e))));
  371.                fprintf(fp,";PD");
  372.                fWrtFFP(fp,(XScale * (XOffset + *x)));
  373.                fprintf(fp," ");
  374.                fWrtFFP(fp,(YScale * (YOffset + (*y + *e))));
  375.                fprintf(fp,";\n");
  376.             }
  377.          }
  378.       }
  379.       Plot = Plot->NextPlot;
  380.    }
  381.  
  382.    fprintf(fp,"SR%f %f;\n",
  383.          (float)(100*P_CH_WID) / (P_XREG - P_LMARGIN - P_RMARGIN),
  384.          (float)(100*P_CH_HEI) / (P_YREG - P_BMARGIN - P_TMARGIN));
  385.    WrtAxes(fp, Pict->Tics, Pict->Grid);
  386.  
  387.    fprintf(fp, "SP;");
  388.    (void) fclose(fp);
  389.    PlotNum++;
  390.    return(TRUE);
  391. }
  392.  
  393.  
  394. To_mCAD(Pict)
  395. struct Pict *Pict;
  396. {
  397.    FILE *fp;
  398.    short i;
  399.    struct Plot *Plot;
  400.    FFP *x, *y, *e, xtmp, ytmp, xtmp1, ytmp1;
  401.    FFP xptsiz, yptsiz, XReg, YReg, XScale, XOffset;
  402.    char plotname[30], *chptr;
  403.    static char mPlotNum = 0;
  404.  
  405.    strcpy(plotname,filename);
  406.    if (chptr = stpchr(plotname,'.')) {
  407.       chptr[1]='c'; chptr[2]='a'; chptr[3]='d';
  408.       chptr[4] = '0' + mPlotNum; chptr[5]=0;
  409.    }
  410.    else {
  411.       i=strlen(plotname); plotname[i]='.';
  412.       plotname[i+1]='c'; plotname[i+2]='a'; plotname[i+3]='d';
  413.       plotname[i+4] = '0' + mPlotNum; plotname[i+5]=0;
  414.    }
  415.    
  416.    if (!(fp = fopen(plotname,"w") ))
  417.       {printf("can't open %s\n",plotname); return(FALSE);}
  418.  
  419.    XReg = Pict->CurrReg->XMax - Pict->CurrReg->XMin;
  420.    YReg = Pict->CurrReg->YMax - Pict->CurrReg->YMin;
  421.    XScale = YReg/XReg * 1.4434; XOffset = Pict->CurrReg->XMin;
  422.  
  423.    Plot = Pict->Plot;
  424.    while (Plot) {
  425.       if (Plot->Enabled) {
  426.  
  427.          /* PLOT LINES */
  428.          if (Plot->PointSize <= 0) {
  429.             x=Plot->x; y=Plot->y;
  430.             for (i=1; i<Plot->NPts; i++, x++, y++) {
  431.                xtmp = XScale * (*x - XOffset);
  432.                fprintf(fp, "%f %f\n", xtmp, *y);
  433.             }
  434.             fprintf(fp,"*>\n*C %d\n\n", 1+Plot->Color-PLOTCOLORBASE);
  435.          }
  436.  
  437.          /* PLOT POINTS */
  438.          if (Plot->PointSize != 0) {
  439.             xptsiz = abs(Plot->PointSize) * (XReg / 582.);
  440.             xptsiz = XScale * xptsiz;
  441.             yptsiz = abs(Plot->PointSize) * (YReg / 360.);
  442.             x=Plot->x; y=Plot->y;
  443.             for (i=0; i<Plot->NPts; i++, x++, y++) {
  444.                xtmp = XScale * (*x - XOffset);
  445.                xtmp -= xptsiz/2;
  446.                ytmp = *y - yptsiz/2;
  447.                fprintf(fp,"%f %f\n", xtmp, ytmp); xtmp += xptsiz;
  448.                fprintf(fp,"%f %f\n", xtmp, ytmp); ytmp += yptsiz;
  449.                fprintf(fp,"%f %f\n", xtmp, ytmp); xtmp -= xptsiz;
  450.                fprintf(fp,"%f %f\n", xtmp, ytmp); ytmp -= yptsiz;
  451.                fprintf(fp,"%f %f\n", xtmp, ytmp);
  452.                fprintf(fp,"*>\n*C %d\n\n", 1+Plot->Color-PLOTCOLORBASE);
  453.             }
  454.          }
  455.  
  456.          /* PLOT ERROR BARS */
  457.          if (Pict->ShowErr) {
  458.             x=Plot->x; y=Plot->y; e=Plot->e;
  459.             for (i=0; i<Plot->NPts; i++, x++, y++, e++) {
  460.                xtmp = XScale * (*x - XOffset);
  461.                ytmp = *y - *e;
  462.                fprintf(fp,"%f %f\n", xtmp, ytmp);
  463.                ytmp = *y + *e;
  464.                fprintf(fp,"%f %f\n", xtmp, ytmp);
  465.                fprintf(fp,"*>\n*C %d\n\n", 1+Plot->Color-PLOTCOLORBASE);
  466.             }
  467.          }
  468.       }
  469.       Plot = Plot->NextPlot;
  470.    }
  471.  
  472.    /*** DRAW TICS/GRID ***/
  473.    x = Pict->Tics->x; y = Pict->Tics->y;
  474.    for (i=1; i < Pict->Tics->NX; i++) {
  475.       xtmp = XScale * (x[i] - XOffset);
  476.       if (Pict->Grid) {
  477.          PToU(Pict, 0, YMINP, &xtmp, &ytmp);
  478.          PToU(Pict, 0, YMAXP, &xtmp1, &ytmp1);
  479.          fprintf(fp,"%f %f\n%f %f\n*>\n*C 2\n\n", xtmp, ytmp, xtmp, ytmp1);
  480.       }
  481.       else {
  482.          PToU(Pict, 0, YMINP, &xtmp1, &ytmp);
  483.          fprintf(fp,"%f %f\n", xtmp, ytmp);
  484.          PToU(Pict, 0, YMINP+X_TIC_SIZE, &xtmp1, &ytmp1);
  485.          fprintf(fp,"%f %f\n*>\n*C 3\n\n", xtmp, ytmp1);
  486.          PToU(Pict, 0, YMAXP, &xtmp1, &ytmp);
  487.          fprintf(fp,"%f %f\n", xtmp, ytmp);
  488.          PToU(Pict, 0, YMAXP-X_TIC_SIZE, &xtmp1, &ytmp1);
  489.          fprintf(fp,"%f %f\n*>\n*C 3\n\n", xtmp, ytmp1);
  490.       }
  491.    }
  492.    for (i=1; i < Pict->Tics->NY; i++) {
  493.       if (Pict->Grid) {
  494.          PToU(Pict, XMINP, YMINP, &xtmp, &ytmp);
  495.          xtmp = XScale * (xtmp - XOffset);
  496.          PToU(Pict, XMAXP, YMAXP, &xtmp1, &ytmp1);
  497.          xtmp1 = XScale * (xtmp1 - XOffset);
  498.          fprintf(fp,"%f %f\n%f %f\n*>\n*C 2\n\n", xtmp, y[i], xtmp1, y[i]);
  499.       }
  500.       else {
  501.          PToU(Pict, XMINP, 0, &xtmp, &ytmp);
  502.          xtmp = XScale * (xtmp - XOffset);
  503.          fprintf(fp,"%f %f\n", xtmp, y[i]);
  504.          PToU(Pict, XMINP+Y_TIC_SIZE, 0, &xtmp1, &ytmp1);
  505.          xtmp1 = XScale * (xtmp1 - XOffset);
  506.          fprintf(fp,"%f %f\n*>\n*C 3\n\n", xtmp1, y[i]);
  507.          PToU(Pict, XMAXP, 0, &xtmp, &ytmp);
  508.          xtmp = XScale * (xtmp - XOffset);
  509.          fprintf(fp,"%f %f\n", xtmp, y[i]);
  510.          PToU(Pict, XMAXP-Y_TIC_SIZE, 0, &xtmp1, &ytmp1);
  511.          xtmp1 = XScale * (xtmp1 - XOffset);
  512.          fprintf(fp,"%f %f\n*>\n*C 3\n\n", xtmp1, y[i]);
  513.       }
  514.    }
  515.  
  516.    /*** PRINT TIC VALUES ***/
  517. /*
  518. *   for (i=0; i < Pict->Tics->NX; i++) {
  519. *      n = sprintf(tmpstr, "%-.4f", Pict->Tics->x[i]);
  520. *      n = min(n, 7);
  521. *      while (tmpstr[n-1] == '0') n--;
  522. *      tmpstr[n]=0;
  523. *   }
  524. *   for (i=0; i < Pict->Tics->NY; i++) {
  525. *      n = sprintf(tmpstr, "%-.4f", Pict->Tics->y[i]);
  526. *      n = min(n, 7);
  527. *      while (tmpstr[n-1] == '0') n--;
  528. *      tmpstr[n]=0;
  529. *   }
  530. */
  531.  
  532.    /*** DRAW AXES ***/
  533.    PToU(Pict, XMINP, YMINP, &xtmp, &ytmp);
  534.    xtmp = XScale * (xtmp - XOffset);
  535.    PToU(Pict, XMAXP, YMAXP, &xtmp1, &ytmp1);
  536.    xtmp1 = XScale * (xtmp1 - XOffset);
  537.    fprintf(fp, "%f %f\n", xtmp, ytmp);
  538.    fprintf(fp, "%f %f\n", xtmp1, ytmp);
  539.    fprintf(fp, "%f %f\n", xtmp1, ytmp1);
  540.    fprintf(fp, "%f %f\n", xtmp, ytmp1);
  541.    fprintf(fp, "%f %f\n", xtmp, ytmp);
  542.    fprintf(fp,"*C 1\n\n");
  543.  
  544.    (void) fclose(fp);
  545.    mPlotNum++;
  546.    return(TRUE);
  547. }
  548.